let mysql = require('mysql');

// 创建mysql的连接池
let pool = mysql.createPool({
    host: 'localhost',
    port: 3306,
    user: 'root',
    password: 'root',
    database: 'yiLiao',
    multipleStatements:true
})

function query(sql) {
    return new Promise((resolve, reject) => {
        pool.query(sql, (err, data) => {
            if (err) {
                reject('数据操作错误')
                return
            }
            resolve(data)
        })
    })
}

module.exports = query;
// module.exports.query = query;